﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using ModularAndPlugin.Core;
using ModularAndPlugin.Core.Composition;
using ModularAndPlugin.Core.IOC.ServiceLocation;
using ModularAndPlugin.Core.ObjectUtil;

namespace UI.Web.MVC.Common.Filter
{
    [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
    public class DemoActionAttributeFilter : ActionFilterAttribute
    {
        public string Message { get; set; }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {

            filterContext.HttpContext.Response.Write(@"<br />After Action execute" + "\t " + Message);
            base.OnActionExecuted(filterContext);
        }

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            filterContext.HttpContext.Response.Write(@"<br />Before Action execute" + "\t " + Message);
            base.OnActionExecuting(filterContext);
        }

        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            filterContext.HttpContext.Response.Write(@"<br />After ViewResult execute" + "\t " + Message);
            base.OnResultExecuted(filterContext);
        }

        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            filterContext.HttpContext.Response.Write(@"<br />Before ViewResult execute" + "\t " + Message);
            base.OnResultExecuting(filterContext);
        }
    }
}
